home *** CD-ROM | disk | FTP | other *** search
- // ArrayOf.h
-
- #ifndef ArrayOf_h
- #define ArrayOf_h
-
- #ifndef Integers_h
- #include "Integers.h"
- #endif
- #ifndef DebugMessage_h
- #include "DebugMessage.h"
- #endif
- #ifndef Assert_h
- #include "Assert.h"
- #endif
- #ifndef Range_h
- #include "Range.h"
- #endif
- #ifndef ConstArrayOf_h
- #include "ConstArrayOf.h"
- #endif
-
- // The includes above have been flattened so that weak compilers
- // can cope better.
-
- template < class Element >
- class ArrayOf: public ConstArrayOf< Element >
- {
- public:
- typedef typename ArrayOf< Element > ArrayType;
- typedef typename ConstArrayOf< Element > ConstArrayType;
- typedef int32 (*Comparison)( const Element&, const Element& );
-
- private:
- ArrayOf( ConstArrayType theArrayOf )
- : ConstArrayOf< Element >( theArrayOf )
- {}
-
- public:
- ArrayOf() {}
- ArrayOf( Element *theStart, uint32 theLength )
- : ConstArrayOf< Element >( theStart, theLength )
- {}
-
- Element *Start() const { return const_cast<Element *>( this->ConstArrayType::Start() ); }
- Element *End() const { return const_cast<Element *>( this->ConstArrayType::End() ); }
-
- Element& operator[]( uint32 i ) const
- { return const_cast<Element &>( ConstArrayType::operator[]( i ) ); }
-
- const ArrayType Head( uint32 position ) const { return this->ConstArrayType::Head( position ); }
- const ArrayType Tail( uint32 position ) const { return this->ConstArrayType::Tail( position ); }
- const ArrayType Middle( URange32 range ) const { return this->ConstArrayType::Middle( range ); }
-
- void Append( ArrayType tail ) { this->ConstArrayType::Append( tail ); }
- void Prepend( ArrayType head ) { this->ConstArrayType::Prepend( head ); }
-
- void operator+=( ArrayType tail ) { this->ConstArrayType::Append( tail ); }
- const ArrayType operator+( ArrayType tail ) { return this->ConstArrayType::operator+( tail ); }
-
- const ArrayType operator&( ConstArrayType r ) const { return this->ConstArrayType::operator&( r ); }
- void operator|=( ArrayType r ) { this->ConstArrayType::operator|=( r ); }
- const ArrayType operator|( ArrayType r ) const { return this->ConstArrayType::operator|( r ); }
- const ConstArrayType operator|( ConstArrayType r ) const { return this->ConstArrayType::operator|( r ); }
-
- uint32 operator<<( ConstArrayType r ) const; // returns the amount copied
- uint32 BitwiseCopy( ConstArrayType r ) const;
-
- void SortBy( Comparison ) const;
- };
-
- #ifndef ArrayOf_cp
- #include "ArrayOf.cp"
- #endif
-
- #endif
-